import { queryCurrent } from '@/services/user';
import { BASE_URL } from '@/utils/url';
import Axios from 'axios';
import { history } from 'umi';
/*
  获取用户角色
**/
export const currentUserRole = async () => {
  try {
    const currentUser = await queryCurrent();
    const currentRole = currentUser.data.roleName;
    return currentRole;
  } catch (e) {
    history.replace({
      pathname: '/user/login',
    });
  }
};

/*
  获取用户角色
**/
export const currentUserDetail = async () => {
  try {
    const response = await queryCurrent();
    const currentUser = response.data.user;
    return currentUser;
  } catch (e) {
    history.replace({
      pathname: '/user/login',
    });
  }
};
